package com.xyzwps.example.data;

public class Demo {

    public static void main(String[] args) {
        Trie trie = new Trie();
        trie.add("PPP".toCharArray());
        trie.add("PPPP".toCharArray());
        trie.add("P2P".toCharArray());
        trie.add("PPT".toCharArray());
        trie.add("Tom".toCharArray());
        trie.add("Thomas".toCharArray());
        System.out.println(trie);

        System.out.println(trie.match("PP")); //     []
        System.out.println(trie.match("PPP")); //    [3]
        System.out.println(trie.match("PPPP")); //   [3,4]
        System.out.println(trie.match("PPT")); //    [3]
        System.out.println(trie.match("PPPPPP")); // [3,4]
        System.out.println(trie.match("Tom")); //    [3]
        System.out.println(trie.match("PPTom")); //  [3]

        System.out.println(trie.match("PPTom", 2)); // [5]
    }
}
